#include "back_center_detection/detection_manager.hpp"

namespace back_center_detection{

    void DetectionManager::registerDetector(const std::string& name,
                                            std::shared_ptr<DetectorBase> detector) {
        detectors_[name] = detector;
    }

    std::shared_ptr<DetectorBase> DetectionManager::getDetector(const std::string& name) {
        auto it = detectors_.find(name);
        if(it != detectors_.end()) {
            return it->second;
        }
        return nullptr;
    }

    bool DetectionManager::detect(const std::string& detector_name, 
                                DetectorBase::PointCloud cloud,
                                geometry_msgs::msg::PointStamped& center_point) {
        auto detector = getDetector(detector_name);
        if(detector){
            return detector->detectCenter(cloud, center_point);
        }
        return false;
    }

}